package com.sztz.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.sztz.entity.User;
import com.sztz.excel.LocalDateTimeConverter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 用户信息ExcelVo实体类，导入导出专用
 * @author yzy
 * @date 2022/7/26 17:27
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserExcelVo {
    /**
     * 用户账户名
     */
    @ExcelProperty(value = "用户账户名",index = 0)
    private String userCode;
    /**
     * 用户名
     */
    @ExcelProperty(value = "用户名",index =1)
    private String name;
    /**
     * 用户性别
     */
    @ExcelProperty(value = "用户性别",index =2)
    private Integer sex;
    /**
     * 用户手机号
     */
    @ExcelProperty(value = "用户手机号",index =3)
    private String phone;
    /**
     * 用户所属企业
     */
    @ExcelProperty(value = "所属企业",index = 4)
    private String firmId;
    /**
     * 用户创建时间
     */
    @ExcelProperty(value = "创建时间",index =5 , converter = LocalDateTimeConverter.class)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * ExcelVo对象转为实体对象
     * @author yzy
     * @date 2022/08/02 18:56
     */
    public User convertToUser(){
        User user = new User();
        user.setUserCode(this.getUserCode());
        user.setUserName(this.getName());
        user.setSex(this.getSex());
        user.setPhone(this.getPhone());
        return user;
    }
}
